

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import data.Data;


@SuppressWarnings("serial")
public class DialogExceptionSlice extends JDialog implements ActionListener {

	private final JPanel contentPanel = new JPanel();
	private JSlicePanel panel;
	private JButton btnAnnulation;
	private JButton btnAccueil;
	private Data data;

	/**
	 * Create the dialog.
	 */
	public DialogExceptionSlice(JSlicePanel panel, Data data) {
		this.data = data;
		this.panel = panel;
		this.setModal(true);
		setTitle("No results");
		setResizable(false);
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		JLabel labelMessageErreur = new JLabel("No results found for your query.\n");
		labelMessageErreur.setToolTipText("");
		labelMessageErreur.setBounds(138, 44, 158, 56);
		contentPanel.add(labelMessageErreur);
		
		JLabel labelMessageErreur2 = new JLabel("Two possibilities:");
		labelMessageErreur2.setBounds(169, 97, 87, 28);
		contentPanel.add(labelMessageErreur2);
		
		btnAnnulation = new JButton("Remove last Slice\r\n");
		btnAnnulation.setBounds(48, 148, 149, 35);
		contentPanel.add(btnAnnulation);
		btnAnnulation.addActionListener(this);
		
		btnAccueil = new JButton("Back to query menu");
		btnAccueil.setBounds(217, 148, 143, 35);
		contentPanel.add(btnAccueil);
		btnAccueil.addActionListener(this);
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {

		if (arg0.getSource() == btnAnnulation) {
			data.removeLastArgument();
			panel.suppDernierPredicat();
			
			this.dispose();
		} else if(arg0.getSource() == btnAccueil) {
			JLegendPanel.getInter().affichQuery();
			this.dispose();

		}
	}
}
